package com.colortea.action.frontstage.membercenter;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.colortea.action.backstage.base.BaseTAction;
import com.colortea.action.backstage.utils.BaseTools;
import com.colortea.action.backstage.utils.enums.BaseEnums.DataUsingState;
import com.colortea.action.backstage.utils.statickey.StaticKey;
import com.colortea.entity.MemberInvoiceT;
import com.colortea.entity.MemberT;
import com.colortea.service.MemberInvoiceTService;
import com.colortea.service.impl.Serial;
import com.opensymphony.xwork2.ActionContext;

@ParentPackage("colortea")
@Namespace("/mcenter")
@InterceptorRefs({ @InterceptorRef("defaultStack") })
public class InvoiceAction extends BaseTAction{
	@Resource
	private MemberInvoiceTService memberInvoiceTService;
	
	@Action(value = "saveInvoice", results = { @Result(name = "json", type = "json") })
	public String saveInvoice(){
		MemberT member=(MemberT)ActionContext.getContext().getSession().get(StaticKey.MEMBER_SESSION_KEY);
		if(member!=null){
			MemberInvoiceT mi=new MemberInvoiceT();
			mi.setId(this.getSerial().Serialid(Serial.MEMBERINVOICE));
			mi.setInvpayee(this.getInvpayee());
			mi.setMemberid(member.getId());
			mi.setCreatorid(member.getId());
			mi.setCreatetime(BaseTools.getSystemTime());
			mi.setUpdatetime(BaseTools.getSystemTime());
			mi.setStatus(DataUsingState.USING.getState());
			memberInvoiceTService.save(mi);
			this.setSucflag(true);
		}
		return JSON;
	}
	
	

	/**
	 * 发票抬头
	 */
	private String invpayee;
	private boolean sucflag;
	
	public boolean isSucflag() {
		return sucflag;
	}
	public void setSucflag(boolean sucflag) {
		this.sucflag = sucflag;
	}
	public String getInvpayee() {
		return invpayee;
	}
	public void setInvpayee(String invpayee) {
		this.invpayee = invpayee;
	}

	
	
	
}
